import { QueryPageDto } from '../dto/query.page.dto';

export function GetSkit(query: QueryPageDto<any>) {
  return {
    skip: (query.page - 1) * query.size,
    take: +query.size,
  };
}

export function GetSort(query: QueryPageDto<any>) {
  if (!query.sort) return { orderBy: {} };
  return {
    orderBy: {
      [query.sort]: query.order,
    },
  };
}
